package com.czxy.dao;

import com.czxy.domain.Qian;
import com.czxy.domain.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author 嗨皮骚
 * @version v 1.0
 * @date 2019/5/9
 */
public interface QianDaoMapper {
    @Insert("INSERT into qiandao values (#{uid},#{date})")
    int insetQianDao(Qian qian);

    @Update("UPDATE USER SET qdnum=qdnum+1 WHERE uid=#{uid}")
    int updateUserQdnum(Qian qian);

    @Results(id = "xx",value = {
            @Result(property = "date",column = "data_day")
    })
    @Select("select * from qiandao where uid=#{uid} ORDER BY data_day ASC")
    List<Qian> findQianDaoByUid(@Param("uid") String uid);

    @ResultMap("xx")
    @Select("select * from qiandao where uid=#{uid} and data_day=#{date}")
    List<Qian> findQianDaoByUidDate(Qian qian);

    @Select("select qdNum from user where uid=#{uid}")
    int userQianDaoNum(User loginUser);

    @Select("delete from qiandao where data_day>='2019-01-01' and data_day<='${y}-${m}-31'")
    void upDatabaseDate(@Param("y") String y, @Param("m") String i);
}
